package com.py.nginxanalysis.util;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ResourceBundle;
import java.util.TimerTask;

public class RunTimeTask extends TimerTask {

    private int record = 0;
    private String path = "";

    @Override
    public void run() {
        int newRecord = 0;
        ResourceBundle resource = ResourceBundle.getBundle("path");  // 读取自定义配置文件
        SimpleDateFormat mf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String accDate = mf.format(date);
        //path.properties的runtime
        String filePath = resource.getString("path.runtime")+accDate+".logs.reqtime";
        if (!this.path.equals(filePath)) {
            this.path = filePath;
            this.record = 0;
        }
        AnalysisUtil util = new AnalysisUtil();
        newRecord = util.runTimeAnalysis(record,path);
        this.record = newRecord;
    }

}
